package com.nereyda.application.managers
{
	import com.nereyda.application.Globals;
	
	public class AppResourceManager
	{
		public static const RSRC_ICON       :String = "icons";
		public static const RSRC_STYLESHEET :String = "styles";
		public static const RSRC_IMAGE      :String = "images";
		
		/**
		 * Devuelve la ruta de acceso completa relativa
		 * al root de la aplicación, para localizar el
		 * recurso especificado.
		 */
		public function getResourcePath( rsrcType:String ):String
		{
			var rsrcPath :String = "";

			rsrcPath = "assets/" + rsrcType + "/";

			if ( rsrcType != RSRC_STYLESHEET ) 
			{
				rsrcPath += Globals.getInstance().currentStyleScheme + "/";
			}
			
			return( rsrcPath );
		}

		/**
		 * Devuelve la ruta de acceso completa (incluido el nombre de
		 * archivo) relativa al root de la aplicación.
		 */
		public function getResourceFilename( rsrcType:String, rsrcName:String = null ):String
		{
			var rsrcPath :String = this.getResourcePath( rsrcType );
			
			if ( (rsrcType == RSRC_STYLESHEET) && !rsrcName ) {
				rsrcName = Globals.getInstance().currentStyleScheme + ".css";
			}
			
			rsrcPath += rsrcName;
			
			return( rsrcPath );
		}
		
		// Devuelve una instancia única de la clase.
		//
		private static var instance :AppResourceManager = null;
		
		public static function getInstance():AppResourceManager
		{
			if ( instance == null )
				instance = new AppResourceManager();
			
			return( instance );
		}
	}
}